//Bits in the Line Control register

#define LCONT_WORDLEN_LSB   1
#define LCONT_WORDLEN_MSB   2
#define LCONT_STOP          4
#define LCONT_PARITY_ENABLE 8
#define LCONT_PARITY_SELECT 16
#define LCONT_PARITY_ONE    32
#define LCONT_BREAK         64
#define LCONT_DLAB          128

//Handshaking flags in the Modem Control register

#define MCONT_DTR      1
#define MCONT_RTS      2
#define MCONT_OUT1     4
#define MCONT_OUT2     8

//Bits in the Line Status register

#define LSTAT_DATA_READY    1
#define LSTAT_OVERRUN       2
#define LSTAT_PARITY_ERROR  4
#define LSTAT_FRAME_ERROR   8
#define LSTAT_BREAK_INT     16
#define LSTAT_THRE          32
#define LSTAT_TSRE          64

//Bits in the Interrupt Enable register

#define ENABLE_DATA_AVAILABLE  1
#define ENABLE_THRE            2
#define ENABLE_RCVLINESTAT     4
#define ENABLE_MODEM_STAT      8

#define ENABLE_ALL (1|2|4|8)

//Bits in the Modem Status register

#define MSTAT_DELTA_CTS    1
#define MSTAT_DELTA_DSR    2
#define MSTAT_TERI         4
#define MSTAT_DELTA_RSLD   8
#define MSTAT_CTS          16
#define MSTAT_DSR          32
#define MSTAT_RI           64
#define MSTAT_RLDS         128

//Parity Values

#define PARITY_NONE        0
#define PARITY_ODD         1
#define PARITY_EVEN        2

//Errors to return

#define PARITY_ERROR       1
#define FRAME_ERROR        2
#define BREAK_ERROR        3

extern int port_ads;       //base address of the UART,Set globally

//add for com3-6 defines*******************************
//defines*********************************************
#define COM1 0
#define COM2 1
#define COM3 2
#define COM4 3
#define COM5 4
#define COM6 5
#define COM7 6
#define COM8 7
//define  sharing interrupts**************************
#define INT1 1
#define INT2 2
#define INT3 4
#define INT4 8
#define INT_ADDR 0X24c
//define interrupts control**************************
#define OPEN_IRQ4   0XEF
#define CLOSE_IRQ4  0X10
#define OPEN_IRQ5   0XDF
#define CLOSE_IRQ5  0X20
#define OPEN_IRQ7   0X7F
#define CLOSE_IRQ7  0X80
#define OPEN_IRQ2   0XFB
#define CLOSE_IRQ2  0X04
#define OPEN_IRQ10  0XFB
#define CLOSE_IRQ10 0X04

//define interrupts vector***************************
#define IRQ4_V  0X0C
#define IRQ5_V  0X0D
#define IRQ7_V  0X0F
#define IRQ10_V 0X72


//defines for error contral****************************
#define ERROR_DC	0X01
#define ERROR_AC	0X02
#define ERROR_SVR	0X04
#define ERROR_ALT	0X08
#define ERROR_NSK	0X10
#define ERROR_GPS	0X20
#define ERROR_TMP	0X40
#define ERROR_DENO	0X80
#define ERROR_AD_GYRO	0X01
#define ERROR_AD_IN	0X02
#define ERROR_AD_OUT	0X04
#define ERROR_TMP_CTL	0X08
#define ERROR_RAM	0X10
#define ERROR_CHIP	0X20 
#define ERROR_COM	0X80





//Ring buffer definition
#ifdef NOTHING
typedef      struct tag_ring{
   int       count;
   int       start;
   int       chext;
   int       size;
   char*     buffer;
}RING;
#endif

#ifndef BYTE
typedef unsigned char BYTE;
#endif
typedef char  BOOLEAN;
#define TRUE  1
#define FALSE 0

void comparm(int parity,int stop,int databits);
void baudset(long baudrate);